package com.dumian.apple.DatabaseTest;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * 数据库表
 * create table Book（
 * id integer primary key autoincrement,
 * author text）
 *
 */

public class MyDatabaseHelper extends SQLiteOpenHelper {
    public static final String CREATE_BOOK="create table Book("+
            "id integer primary key autoincrement,"+"author text,"+
            "price real,"+"pages integer,"+"name text,)";
    private Context mContext;
/**
 * 选择较少参数的构造方法 1 Context 2数据库名 3查询数据库返回一个自定义的Cursor(一般传入null) 4当前数据库版本号
 * */
    public MyDatabaseHelper(Context context, String name,
                            SQLiteDatabase.CursorFactory factory,
                            int version) {
        super(context, name, factory, version);
        mContext = context;
    }
    @Override
    public void onCreate(SQLiteDatabase db){
        db.execSQL(CREATE_BOOK);
        Toast.makeText(mContext,"Create Succeeded",Toast.LENGTH_SHORT).show();
    }
    @Override
    public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){

    }

}
